package com.boot2551.control;

import com.boot2551.bean.Salgrade;
import com.boot2551.service.SalgradeS;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping(value = "sal")
public class SalgradeC {
    @Resource
    public SalgradeS ss;
    @RequestMapping(value = "/insert")
    @ResponseBody
    public int insert(Salgrade s){
        return ss.insert(s);
    }
    @RequestMapping(value = "/all")
    @ResponseBody
    public List<Salgrade> all(){
        return ss.all();
    }
    @RequestMapping(value = "/del")
    @ResponseBody
    public int del(int id){
        return ss.delete(id);
    }

    /**
     * 如果页面参数与方法参数不一致，则需要请求参数配置
     * @param id
     * @return
     */
    @RequestMapping(value = "/one")
    @ResponseBody
    public Salgrade one(@RequestParam(value = "grade") int id) {
        return ss.one(id);
    }
    @RequestMapping(value = "/update")
    @ResponseBody
    public int update(Salgrade s){
        return ss.update(s);
    }
}
